package com.nowar.data.controller;

import com.nowar.common.result.response.ResponseCommonBase;
import com.nowar.common.util.SnowFlakeUtil;
import com.nowar.data.entity.UserInfoEntity;
import com.nowar.data.entity.vo.UserInfoVo;
import com.nowar.data.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 谢无殇。
 * @Date : 2023-02-22 2 2:05
 */
@RestController
@RequestMapping(value = "user")
public class UserInfoController {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
    @Autowired
    private UserInfoService userInfoService;

    @PostMapping(value = "userInfo")
    public ResponseCommonBase getUserInfoEntity(@RequestBody UserInfoEntity userInfo) {
        applicationEventPublisher.publishEvent(userInfo);
        UserInfoVo userInfoEntity = userInfoService.getUserInfoEntity(userInfo);
        ResponseCommonBase<UserInfoVo> responseBase = ResponseCommonBase.ok(userInfoEntity);
        return responseBase;
    }
}
